\usemodule[visual]

\setuppapersize[B5]
\setuplayout[width=fit,height=fit,backspace=10mm,cutspace=10mm,topspace=10mm,margin=10mm,header=10mm,footer=10mm]
\setuppagenumbering[location={header,right},style=\bfb]

\setupinteraction[state=start,color=black]
\starttext

% % % ================== 代码示例 - 6：层级标题的样式

\define[1]\numstyle
{
    ({\darkgreen #1})
}

\setupheadtext[content=Table of Contents]
\setuplist
    [chapter]
    [before=\blank[6pt], after=\blank[8pt], numberstyle={\bf\darkred}, textstyle={\bfb\darkred}]
\setuplist
    [section]
    [margin=2em,numbercommand=\numstyle]
\setuplist
    [subsection]
    [margin=4em,numbercommand=\numstyle]
\completecontent[alternative=c]
\chapter[chapter1]{Chapter 1}
\section{Section 1}
\subsection{Sub 1}
\fakewords{10}{20}
\subsection{Sub 2}
\fakewords{30}{40}
\section{Section 2}
\fakewords{10}{30}
\subsection{Sub 1}
\fakewords{10}{30}
\chapter[chapter2]{Chapter 2}
\section{Section 1}
\fakewords{30}{50}
\section{Section 2}
\fakewords{20}{50}

\stoptext